package org.chengn.level_middle.context2487;

import org.chengn.definition.ListNode;

/**
 * @Title: Context2487
 * @Author ChengN
 * @Package org.chengn.level_middle.context2487
 * @Date 2024/1/3 0:23
 * @description: 从链表中移除节点
 */
public class Context2487 {
    public ListNode removeNodes(ListNode head) {
        if (head.next == null) return head;
        ListNode nextNode = removeNodes(head.next);
        if (head.val < nextNode.val) {
            head.val = nextNode.val;
            head.next = nextNode.next;
            return nextNode;
        }
        return head;
    }
}
